package com.sgb.kjwl.view.widget.transport;

import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;

import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.SheetDialogCompanyInfoBinding;
import com.swgk.core.dialog.BaseBottomDialog;
import com.swgk.core.dialog.DialogViewHolder;

/**
 * Describe:
 * Author:  yangLei
 * Date:    2022/1/13
 */
public class InvoiceInfoBottomDialog extends BaseBottomDialog {

    private SheetDialogCompanyInfoBinding mBinding;
    private InvoiceInfo invoiceInfo;

    public void setInvoiceInfo(InvoiceInfo invoiceInfo) {
        this.invoiceInfo = invoiceInfo;
        setData(invoiceInfo);
    }

    public InvoiceInfoBottomDialog(Context context, DialogCallBack dialogCallBack) {
        super(context, dialogCallBack);
    }

    @Override
    protected int dialogLayout() {
        return R.layout.sheet_dialog_company_info;
    }

    @Override
    protected void initView(DialogViewHolder holder, Bundle savedInstanceState) {
        mBinding = (SheetDialogCompanyInfoBinding) holder.getmBinding();
        mBinding.close.setOnClickListener(v -> dismiss());
        setCanceledOnTouchOutside(false);
        setData(invoiceInfo);
    }

    private void setData(InvoiceInfo info) {
        if (mBinding == null || info == null)
            return;
        mBinding.companyName.setText(!TextUtils.isEmpty(info.getCompanyName()) ? info.getCompanyName() : "/");

        mBinding.dutyNum.setText(!TextUtils.isEmpty(info.getTaxID()) ? info.getTaxID() : "/");

        mBinding.address.setText(!TextUtils.isEmpty(info.getAddress()) ? info.getAddress() : "/");

        mBinding.phone.setText(!TextUtils.isEmpty(info.getPhone_number()) ? info.getPhone_number() : "/");

        mBinding.bank.setText(!TextUtils.isEmpty(info.getBank_name()) ? info.getBank_name() : "/");

        mBinding.bankAccount.setText(!TextUtils.isEmpty(info.getBank_account()) ? info.getBank_account() : "/");

        mBinding.bankNub.setText(!TextUtils.isEmpty(info.getBan_no()) ? info.getBan_no() : "/");

    }

    /**
     * 发票信息类
     */
    public static class InvoiceInfo {
        private String companyName;
        private String taxID;
        private String address;
        private String phone_number;
        private String bank_name;
        private String bank_account;
        private String ban_no;

        public InvoiceInfo(String companyName, String taxID, String address, String phone_number, String bank_name, String bank_account, String ban_no) {
            this.companyName = companyName;
            this.taxID = taxID;
            this.address = address;
            this.phone_number = phone_number;
            this.bank_name = bank_name;
            this.bank_account = bank_account;
            this.ban_no = ban_no;
        }

        public String getCompanyName() {
            return companyName;
        }

        public void setCompanyName(String companyName) {
            this.companyName = companyName;
        }

        public String getTaxID() {
            return taxID;
        }

        public void setTaxID(String taxID) {
            this.taxID = taxID;
        }

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }

        public String getPhone_number() {
            return phone_number;
        }

        public void setPhone_number(String phone_number) {
            this.phone_number = phone_number;
        }

        public String getBank_name() {
            return bank_name;
        }

        public void setBank_name(String bank_name) {
            this.bank_name = bank_name;
        }

        public String getBank_account() {
            return bank_account;
        }

        public void setBank_account(String bank_account) {
            this.bank_account = bank_account;
        }

        public String getBan_no() {
            return ban_no;
        }

        public void setBan_no(String ban_no) {
            this.ban_no = ban_no;
        }
    }
}
